package com.homedo.microservice.wechat.personal.secretary;

import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.homedo.microservice.wechat.personal.secretary.util.ApplicationContextUtil;
import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;


@Configuration
@SpringBootApplication
@EnableCircuitBreaker
@EnableHystrixDashboard
@ComponentScan(basePackages = {"com.homedo.microservice.wechat.personal.secretary", "io.github.biezhi"})
@EnableAutoConfiguration
//@EnableEurekaClient
//@EnableFeignClients
@EnableApolloConfig
public class WechatPersonalSecretaryApplication extends SpringBootServletInitializer implements ApplicationContextAware {
    public static void main(String[] args) throws Exception {
        SpringApplication.run(WechatPersonalSecretaryApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(WechatPersonalSecretaryApplication.class);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        ApplicationContextUtil.setApplicationContext(applicationContext);
    }
}
